package com.yuexunit.account.action.v2;

import java.util.List;

import com.yuexunit.account.action.v2.model.Operation;
import com.yuexunit.account.action.v2.model.Role;
import com.yuexunit.auth.service.AuthorizationService;
import com.yuexunit.inject.ComponentFactory;
import com.yuexunit.inject.annotation.Implements;
import com.yuexunit.page.PageCriteria;
import com.yuexunit.page.PageList;

/**
 * @author wangjinshui
 */
@Implements(AuthorizationActionApi.class)
public class AuthorizationActionImpl implements AuthorizationActionApi {
	private AuthorizationService authService = ComponentFactory.loadClass(AuthorizationService.class);

	@Override
	public List<Role> inquireRoleList(String appUuid, Long accountId) {
		return authService.inquireRoleList(appUuid, accountId);
	}

	@Override
	public PageList<Role> inquireRolePageList(String appUuid, Long accountId, PageCriteria pageCriteria) {
		List<Role> roleList = inquireRoleList(appUuid, accountId);
		
		PageList<Role> result = new PageList<>(roleList, pageCriteria);
		return result;
	}
	
	
	
	@Override
	public Role inquireRole(Long roleId) {
		return authService.inquireRole(roleId);
	}

	@Override
	public void updateAccountRoles(String appUuid, Long accountId, List<Long> roleIdList) {
		authService.updateAccountRoles(appUuid, accountId, roleIdList);
	}

	@Override
	public List<String> inquireOperationListOfAccount(String appUuid, Long accountId) {
		return authService.inquireOperationListOfAccount(appUuid, accountId);
	}

	@Override
	public Long createRole(String appUuid, String roleName) {
		return authService.createRole(appUuid, roleName);
	}

	@Override
	public void updateRole(String appUuid, Long roleId, String roleName) {
		authService.updateRole(appUuid, roleId, roleName);
	}

	@Override
	public void deleteRole(String appUuid, Long roleId) {
		authService.deleteRole(appUuid, roleId);
	}

	@Override
	public List<Operation> inquireOperationList(String appUuid, Long roleId) {
		return authService.inquireOperationList(appUuid, roleId);
	}

	@Override
	public void updateRoleOperations(String appUuid, Long roleId, List<String> operationCodeList) {
		authService.updateRoleOperations(appUuid, roleId, operationCodeList);
	}
}
